home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
DOUBLEDE
/
MAIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-07-28
|
4KB
|
197 lines
#include "shell.h"
WindowPtr windows[NUMWINDOWS];
ControlHandle demoButton[NUMWINDOWS];
double demo_double[NUMWINDOWS];
Rect screen_rect;
MenuHandle AppleMenu;
MenuHandle FileMenu;
MenuHandle EditMenu;
EventRecord event;
int awaytime;
Boolean chooserAlert;
Boolean quitting;
Boolean quit_on_wind_close;
WindowPtr clip_window;
int scrap_check;
long scrap_size;
Handle scrap_contents;
long scrap_type;
ProcPtr mainloop;
int errno;
int w_index;
/*====================================================================
multimainloop()
an event loop to execute when running under MultiFinder
====================================================================*/
int multimainloop()
{
if (WaitNextEvent(everyEvent,&event,awaytime,NIL))
handleanevent();
fixmenus();
}
/*====================================================================
unimainloop()
an event loop to execute when _not_ running under MultiFinder
====================================================================*/
int unimainloop()
{
SystemTask();
if (GetNextEvent(everyEvent,&event))
handleanevent();
fixmenus();
}
/*====================================================================
multiopening()
called when being launched under MultiFinder, loops until no
events are in the queue, allows application to launch as
frontmost
====================================================================*/
multiopening()
{
Boolean multi_opening;
do{
if (multi_opening = WaitNextEvent(everyEvent,&event,awaytime,NIL))
handleanevent();
}while(multi_opening);
}
/*====================================================================
main()
the main program. Calls routines to initialize Mac Managers, makes
menus & windows, contains the call to the event loop.
====================================================================*/
main()
{
init();
if (WNEavail()){
mainloop = multimainloop; /* MultiFinder event loop */
multiopening();
}
else
mainloop = unimainloop; /* Finder event loop */
makemenus();
makewindows();
chooserAlert = SetChooserAlert(FALSE); /* bypass page setup warning
when choosing a printer */
getourscrap();
quitting = FALSE;
/*
Execute event loop until user quits
*/
while(!quitting)
(*mainloop)();
/*
set cursor to watch during application closing
*/
SetCursor(*(CursHandle)GetCursor(watchCursor));
/*
close application windows, and restore the Chooser
page setup warning
*/
close_app_windows();
SetChooserAlert(chooserAlert);
}
/*====================================================================
close_app_windows()
closes application windows and Desk Accessories that are open when
the user quits the application
====================================================================*/
close_app_windows()
{
WindowPeek wRec;
while ( FrontWindow() != NIL){
wRec = (WindowPeek)FrontWindow();
if ((wRec->windowKind==dialogKind) || (wRec->windowKind==userKind))
HideWindow(FrontWindow());
else
CloseDeskAcc(wRec->windowKind);
}
}
/*====================================================================
easy_out()
An attempt to exit_to_shell (usually the Finder) when a system
error occurs.
====================================================================*/
easy_out()
{
ExitToShell();
}
/*====================================================================
init()
Initialize Macintosh Managers, create master pointers,
initialize random number generator, initialize the global
boolean quit_on_wind_close
====================================================================*/
init()
{
int index;
MaxApplZone();
for (index=1;index<11;index++)
MoreMasters();
InitGraf(&thePort);
InitFonts();
FlushEvents(everyEvent,0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(easy_out);
InitCursor();
randSeed = TickCount();
quit_on_wind_close = TRUE;
awaytime = 60;
screen_rect = screenBits.bounds;
}